const getJSON = function(url) {
    const promise = new Promise(function(resolve, reject) {
        const client = new XMLHttpRequest();
        const loadHandler = () => {
            if (client.readyState !== 4) {
                return;
            }
            if (client.status === 200) {
                resolve(client.response);
            } else {
                reject(new Error(client.statusText));
            }
        };
        client.open("GET", url);
        client.onloadend = loadHandler;
        client.responseType = "json";
        client.setRequestHeader("Accept", "application/json");
        client.send();
    });

    return promise;

};

window.getJSON = getJSON;